﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Dojo & WCF</title>

    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.3.0/dojo/dojo.xd.js" type="text/javascript"></script>

    <script type="text/javascript">
        dojo.require('dojo.parser');
        dojo.require("dojox.rpc.Service");

        var clockProxy;

        dojo.addOnLoad(
            function() {
                clockProxy = new dojox.rpc.Service("ClockService.svc/?smd");
                GetTime();
            }
        );

        function GetTime() {
            clockProxy.GetTime()
                .addCallback(
                    function(data) {
                        dojo.byId('ServerTime').innerHTML = data.d;
                    }
                )
                .addErrback(
                    function(data) {
                        alert(data);
                    }
                );
        }

        function GetLocalTime() {
            clockProxy.GetLocalTime(
                    {cultureName: dojo.byId('culture').value }
                ) 
                .addCallback(
                    function(data) {
                        dojo.byId('LocalServerTime').innerHTML = data.d;
                    }
                )
                .addErrback(
                    function(data) {
                        alert(data);
                    }
                );    
        }    
        
    </script>
</head>
<body>
    <input type="button" value="Time?" onclick="GetTime();" />
    <div id="ServerTime"></div>
    <hr />
    <span>Culture name : </span><input id="culture" type="text" /><span> (ex : en-US; fr-FR etc...)</span>
    <div id="LocalServerTime"></div>
    <input type="button" value="Get local time" onclick="GetLocalTime();" />
</body>
</html>
